var express = require('express'),
    swig = require('swig-templates'),
    request = require('request'),
    wx = require('../base/wx'),
    router = express.Router();
router.get('/',function(req, res,next) {
    wx.goAccessToken(req, res, function () {
        request.get({
            url: config.resourcePath.apiRoot + '/index/index/userOrder?user_id=' + (req.cookies.user_id?req.cookies.user_id:'1')
        }, function (error, response, body) {
            try {
                var result = JSON.parse(body);
                if (result.code == 200) {
                    var rundData = {
                        message: result.message
                    };
                    res.render('page/order-list', rundData);
                }
            } catch (e) {
                var err = new Error('Not Found');
                err.status = 500;
                next(err);
                return;
            }
        });
    });
});
module.exports = router;
